<?php
/*
tag文件内容案例
<psp:filedlist>
goods => goods.id:icon1|goods.goods_name:icon2| ;
shop_info => shop_info.id:icon1|shop_info.shop_name:icon2|;
</psp:filedlist>
<psp:htmlurl>
goods => htmlurl1:good/index/{$_value['icon1']}|htmlurl2:good/index/{$_value['icon1']}?&name={$_value['icon2']}| ;
shop_info => htmlurl1:shop/index/{$_value['icon1']}|htmlurl2:shop/index/{$_value['icon1']}?&name={$_value['icon2']}| ;
[default] => htmlurl1:default/index/{$_value["icon1"]}|htmlurl2:default/index/{$_value["icon1"]}?&name={$_value["icon2"]}| ;
</psp:htmlurl>
<?php foreach( PSP_FIELDLIST_DATA_DEFAULT as $_key => $_value ) { ?>
<?php if ($_value['icon1']) { ?>   
	<a target="_blank" href="{[htmlurl1]}">
		<img width="625" height="90" border="0" src="<?php echo $_value['icon2'] ?>">
	</a> 
	<a target="_blank" href="{[htmlurl2]}">
		wwwwwwwwwwwwwww
	</a> 	
<?php } ?>				
<?php } ?>
*/
Loader::import('pspframework.datasource.ConnectionManager');
Loader::import('pspframework.utils.sessions.PspSession');
class PspTags
{
	public $DbConfig = '';
	
	public $db = '';	

    public $DbPrefix = '';

    public $View = null;
	
    public $pspLayout_out = null;

    public $pspLayout_toplist = '';	
	
    public $pspLayout_pares_data = array();
	
    public $pspLayout_css = true;
	
    public $_filedhtmlurlcode = array();	
	
    public function __construct( & $View = null,$DbConfig = null)
    {
	    $this->View = $View;
	    if($DbConfig ===null) {
		    $DbConfig = 'default';
		}         		
	    $this->db =& ConnectionManager::getDataSource($DbConfig);
		$this->DbPrefix = $this->db->config['prefix'];
    }
 
    public function get_div_data() 
	{   
	    if(empty($this->div_data))
		{
	    $this->div_data = @include (FRAMEWORK_ROOT . DS . 'config' . DS .'FormTypes.php');
		}
		return $this->div_data;
	}
 


    public function pspFormToHtml($str = "",$appname = "") 
	{
	    if(empty($str))return $str;
		$temp_html_array = array();
		$temp_div_array = array();		
		$temp_name = "";	
		$tmep_value1_array = '';			
		$temp_html_array = filterEmptyVar($this->strAttribute($str));
        $value_array =array();
        if(isset($temp_html_array['name']))
		{
		    if(strpos($temp_html_array['name'],'data[')==0) {
			    $temp_html_array['name'] = str_replace(array('][','data[',']'),array('.','',''),$temp_html_array['name']); 
			}
			
			$temp_name ='data['.str_replace(array('.'),array(']['),$temp_html_array['name']) .']';	        
			$temp_html_array['name'] =$temp_name;
		}
  
		foreach($this->get_div_data() as $key => $value)
		{
		    if($temp_html_array['type'] == $value['config']['type'])
			{
			  $temp_div_array = $value;
			}
		}


        if(empty($temp_html_array['value']))
		{
		    $temp_html_array['value'] = '$'.str_replace(array("[","]"),array("['","']"),$temp_name);
		}
				
		if(($temp_html_array['value']{0}!= '$'))
		{									 
 			$temp_value_array = explode("|",$temp_html_array['value']);		 
		 
			foreach($temp_value_array as $key =>$value)
			{
				$tmep = explode(":",$value);
				if(!isset($tmep[1]))
				{
				$tmep[1]='';
				}
				$tmep_value1_array[$tmep[0]]=$tmep[1];		     
		    }
		}
		
        if(!empty($temp_html_array['sxdata']))
		{
		    $sx_temp = @include(CONFIGS . DS .'sx'. DS .$temp_html_array['sxdata']);
			$tmep_value1_array=array();
			if(!empty($temp_html_array['sxdatatype']))
			{
			   foreach((array)$sx_temp['data'] as $key => $value)
			   {
				$tmep_value1_array[$value['str_pad'].$value['name']]=$value['name'];				
			   }				
			}
			else
			{
			   foreach((array)$sx_temp['data'] as $key => $value)
			   {
				$tmep_value1_array[$value['str_pad'].$value['name']]=$value['id'];				
			   }			
			}			
		}	
		$html_str = '';	
		if(is_array($tmep_value1_array))
		{    
			$html_chird = '';
		    foreach($tmep_value1_array as $key=>$value)
		    {		
		       $value_array = array($key,$value);			   			   
		       if(!empty($temp_div_array['html_chird']))
	           {
		        $html_chird .= preg_replace("/\{PSPframework_CONFIG\s*\(\s*(.+?)\s*\)\s*\}/ies", "\$this->_get_config_div('\\1',\$value_array,\$temp_html_array)", $temp_div_array['html_chird']);			 
	           }
			   else
			   {
		        $html_str .= preg_replace("/\{PSPframework_CONFIG\s*\(\s*(.+?)\s*\)\s*\}/ies", "\$this->_get_config_div('\\1',\$value_array,\$temp_html_array)", $temp_div_array['html']);				   
			   }			   			   			   		
		    }
		}
		else
		{		
		    $html_str .= preg_replace("/\{PSPframework_CONFIG\s*\(\s*(.+?)\s*\)\s*\}/ies", "\$this->_get_config_div('\\1',\$value_array,\$temp_html_array)", $temp_div_array['html']);			
   		}	

		if(!empty($temp_div_array['html_chird']))
		{
		    $html_str = preg_replace("/\{PSPframework_CONFIG\s*\(\s*(.+?)\s*\)\s*\}/ies", "\$this->_get_config_div('\\1',\$value_array,\$temp_html_array)", $temp_div_array['html']);
								
	        $html_str =str_replace(array('{PSPframework_CHIRD}'),array($html_chird),$html_str);
		
		}
		
		$html_str = preg_replace("/\{PSPframework_LIST\s*\(\s*(.+?)\s*\)\s*\}/ies", "\$this->_get_list_value_div('\\1',\$appname,\$temp_html_array)", $html_str);	

        return $html_str;

	} 

    public function _get_list_value_div($vname="",$appname="",$html_array=array())
	{  
	    $str = '';
		if($vname=='appname')
		{
		 return $appname;
		}
		if($vname=='name_HtmlId')
		{		    
		 return str_replace(array("data[","[","]"),array("","",""),$html_array[str_replace('_HtmlId','',$vname)]);		 
		}		
        if(isset($html_array[$vname]))
		{ 
			$str = str_replace(array("[","]"),array("['","']"),$html_array[$vname]);			
		}		
		return $str;
	}

	

	
    public function _get_config_div($str="",$value_array=array(),$html_array=array())
	{   

	    $temp_str='';
  		$temp_array = filterEmptyVar(explode("&",$str));

		if(empty($temp_array))
		{
		    foreach($html_array as $key=>$value)
			{
			      if(($value=='disabled'||$value=='selected'||$value=='checked')&&!isset($html_array[$value]))
			      {
	               continue;			
			      }			
	              $temp_str .=  ' '.$key."=\"".$value."\" "; 			
			}
			return $temp_str;		
		}
		//用来开启在标签中添加的formtyp中不存在的属性可以显示而设置的
        if(isset($html_array['startext']) && $html_array['startext'] =='on') {
		    unset($html_array['startext']);
			$k=0;
		    if(!in_array('value',$temp_array)) {
				$k = 1;
		    }			
            foreach($html_array as $key=>$value)
		    {			
		        if(!in_array($key,$temp_array)) {
				    $temp_array[] = $key;
				}
		    }
            if($k) {
			    foreach($temp_array as $key =>$value) {
				    if($value =='value') {
				        unset($temp_array[$key]);
				    }
				}
                
            }			
		}

        if(empty($value_array))
		{
             foreach($temp_array as $key=>$value)
		     {	
			      if(($value=='disabled'||$value=='selected'||$value=='checked')&&!isset($html_array[$value]))
			      {
	               continue;			
			      }			 
			    if($value =='ICON')
			     {
				  return $html_array['value'];			  
				 }
			     if(!isset($html_array[$value]))
				 {
				  $html_array[$value] ='';
				 }
			     $temp_str .=' '.$value."=\"".$html_array[$value]."\" ";		
		     }	
			 return $temp_str;	
		} 	
			
        if(!empty($value_array))
		{
            foreach($temp_array as $key=>$value)
		    {
			     if(($value=='disabled'||$value=='selected'||$value=='checked')&&!isset($html_array[$value]))
			     {
	               continue;			
			     }
				    
			 	 if($value =='ICON')
			     {
				  return $value_array[0];			  
				 }
				 
			 	 if($value =='ICONK')
			     {
				  return $value_array[1];			  
				 }
				 				 
				 if($value =='value')
				{   
				     if(isset($value_array[1]))
					 {
			         $temp_str .=' '.$value."=\"".$value_array[1]."\" ";						 
					 }
					 else
					 {
			         $temp_str .=' '.$value."=\"".$value_array[0]."\" ";						 
					 }
			 
				} elseif($value =='name' && $html_array['type']=='checkbox')
				 {	//对checkbox复选框的标签的name进行处理				 
					//$namestr = $html_array['name'].'[]';					
					$namestr =str_replace('][','.',$html_array['name']);
					$namestr =str_replace(']','',$namestr).'_psp_checkbox_form_]';
					$namestr =str_replace('.','][',$namestr).'[]';					
					
                    $temp_str .=' '.$value."=\"".$namestr."\" ";			     
				} else
				{
				 	 if(!isset($html_array[$value]))
				     {
				     $html_array[$value] ='';
				     }
			         $temp_str .=' '.$value."=\"".$html_array[$value]."\" ";				 
				}
				 
		
		    }	
			 return $temp_str;	
		} 


    }
	
	
	
 /* 
<psp:select type='data' prefixes='' plugin=''  controller=''  action=''  dataid='1' isall='true' > 
	 <psp:select type='filedlist' fieldname='url'>
	 <psp:select type='filedlist' fieldname='urlvalue'>
	 <psp:select type='filedlist' fieldname='urlnovalue'>	 
	 <psp:select type='filedlist' fieldname='name'> 
</psp:select > 
 */ 
	function pspSelectToUrl($str='') 
	{
	    if(empty($str))return $str;
		$temp_html_array = array();	
		$temp_html_array = filterEmptyVar($this->strAttribute($str));
		if($temp_html_array['type'] =='data') {
			if(!isset($temp_html_array['isall'])){
			    $temp_html_array['isall']= true;
			}		
			if(!isset($temp_html_array['plugin'])){
			    $temp_html_array['plugin']='';
			}
			if(!isset($temp_html_array['prefixes'])) {
			    $temp_html_array['prefixes']='';
			}	
            $url = '';			
            if($temp_html_array['plugin']) $url .= $temp_html_array['plugin'].'/';
            if($temp_html_array['prefixes']) $url .= $temp_html_array['prefixes'].'/';
            $file = ucfirst($temp_html_array['plugin']) . ucfirst($temp_html_array['prefixes']) 
				. ucfirst($temp_html_array['controller']) . ucfirst($temp_html_array['action']);
				
		    return'<?php
				$psp_sc_select_filename = "'.$file.'" . ".php";			
				$psp_sc_select_file = CONFIGS . DS ."select". DS . $psp_sc_select_filename ;
				$psp_sc_selectdata = $_psp_sc_selectdata = array();
				if(!isset($this->_SelectCache["'.$file.'"])) {
					if(file_exists($psp_sc_select_file)) {
						$_psp_sc_selectdata = @include ( $psp_sc_select_file );
					    $this->_SelectCache["'.$file.'"] = $_psp_sc_selectdata;						
					}				
				}else {
				    $_psp_sc_selectdata = $this->_SelectCache["'.$file.'"] ;
				}
				if(!empty($_psp_sc_selectdata)) {
					$psp_sc_selectdata = $_psp_sc_selectdata['.intval($temp_html_array['dataid']).'] ;
					if ('.$temp_html_array['isall'].' && !isset( $psp_sc_selectdata["selectlist"]["no"] ) ){
						$psp_sc_selectdata["selectlist"]["no"] = array("title"=>"不限","conditions"=>"1=1" );
					}
                    $__sc_urlnovalue = "";						
					foreach ( $psp_sc_selectdata["selectlist"] as $_key => $_value ) {
						$__sc_url = "'.$url.$temp_html_array['controller'].'/'.$temp_html_array['action'].'"."?&sc=sc" . $psp_sc_selectdata["filedAlias"] .".". $_key ;
						$__sc_urlvalue = "sc" . $psp_sc_selectdata["filedAlias"] .".". $_key ;	
						if($_key=="no") {
						    $__sc_urlnovalue = "'.$url.$temp_html_array['controller'].'/'.$temp_html_array['action'].'"."?&sc=sc" . $psp_sc_selectdata["filedAlias"] .".no" ;
                        }						
						$__sc_name = $_value["title"];									
				?>';		   
		} else if($temp_html_array['type'] =='filedlist'){
		    if($temp_html_array['fieldname']=='url') {
			    return '<?php  echo $this->_url( $__sc_url );?>';
			}else if($temp_html_array['fieldname'] =='name') {
			    return '<?php echo $__sc_name ;?>';
			}else if($temp_html_array['fieldname'] =='urlvalue') {
			    return ' $__sc_urlvalue ';
			}else if($temp_html_array['fieldname'] =='urlnovalue') {
			    return ' $__sc_urlnovalue ';
			}			
		}
		
	}
	
/*实现页面布局用的标签
<psp:layout width='900px' float='' >
	<psp:layout   width='500px' float='left' >	
		<psp:tags     htmlname='default_index_ad1'  iconname='default_index_ad1' />
	</psp:layout>
	<psp:layout   width='300px' float='right' >	
	eeeeeeeeee
	</psp:layout>
</psp:layout>
*/	
    public function PspLayoutToHtmlDiv($str = "",$psplayoutcount=0) 
	{
	    if(empty($str)&&empty($temp_icon_array))return $str;		
		$oldstr = $this->filtrate($str);
        $temp_layout_array = array();
        if(empty($temp_layout_array))	{
		    $temp_layout_array = filterEmptyVar($this->strAttribute($str));		
		}
		$style = 'padding:0px;margin:0px;margin: 0 auto;';
		if(isset($temp_layout_array['padding'])&& !empty($temp_layout_array['padding'])) {
			$style .= 'padding:'.$temp_layout_array['padding'].';';
		}else {
			$style .= 'padding:0px;';
		}
		if(isset($temp_layout_array['margin'])&& !empty($temp_layout_array['margin'])) {
			$style .= 'margin:'.$temp_layout_array['margin'].';';
		}else {
			//$style .= 'margin:0px;';
		}			
		if(isset($temp_layout_array['clear'])&& !empty($temp_layout_array['clear'])) {
			$style .= 'clear:'.$temp_layout_array['clear'].';';
		}else {
			//$style .= 'clear:both;';
		}	
		if(isset($temp_layout_array['float'])&& !empty($temp_layout_array['float'])) {
			$style .= 'float:'.$temp_layout_array['float'].';';
		}else {
			//$style .= 'float:left;';
		}				
		foreach($temp_layout_array as $key => $value) {
			$style .= $key.':'.$value.';';
		}	
		
        if(PspSession::check('TagsViewStartOrStop')) {		   
	        $viewFileName = $this->View->viewPath;
		    $CviewFileName = $this->View->viewCompiledPath;				
		    $MviewFileName = $this->View->viewViewsmanagesPath;	
			if($this->pspLayout_out==null) {
				$nowFileName = $viewFileName;			
                if( file_exists($MviewFileName) ) {
					$nowFileName = $MviewFileName;		   
				}
				if( !file_exists($nowFileName) ) {
					return '';		   
				}			
				$this->pspLayout_out = '';
				$this->pspLayout_out = file_get_contents($nowFileName);
				$this->pspLayout_pares_data = $this->PspLayoutParse($this->pspLayout_out);
			}
            $layoutdata = $this->pspLayout_pares_data[$psplayoutcount];
			if($layoutdata['parentid']==0) {
                $this->pspLayout_toplist .= $layoutdata['id'].',';	
            }			
            $css = '';
			if($this->pspLayout_css==true) {
		        $css ='
				<style>
				.cl{*zoom:1;}
				.cl:after {
					clear: both;
					content: ".";
					display: block;
					height: 0;
					visibility: hidden;
					overflow:hidden; 
					
				}
				.frame {
					min-height: 20px;
					position: relative;
					background-position: 50% 0;
					background: none repeat scroll 0 0 #DDF0DF;	
					border: 1px dashed #0099FF;
					padding-top: 5px;
					margin: 1px;
					z-index: 290;	
				}
				* {
					word-wrap: break-word;
				}
				.edit {
					background: none repeat scroll 0 0 red;
					color: #FFFFFF;
					cursor: pointer;
					line-height: 26px;
					padding: 0 5px;
					position: absolute;
					right: 0;
					top: 0;
					z-index: 199;
				}
				.edit-menu {
					background: none repeat scroll 0 0 #FFFFFF;
					border-color: #DDDDDD #999999 #999999 #CCCCCC;
					border-style: solid;
					border-width: 0 1px 1px;
					position: absolute;
					z-index: 300;
				}
				.mitem {
					border-top: 1px solid #DDDDDD;
					cursor: pointer;
					padding: 4px 4px 4px 14px;
					width: 60px;
					list-style: none outside none;
					color:#0066CC;	
					z-index: 900;	
				}
				.mitem a{
					color:#0066CC;
	                text-decoration:none;					
				}					
				</style>';			
			    $this->pspLayout_css =false;
			}
            
            $editlayout_url = $this->View->base.'/index.php/psplayouts/editlayout/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];			
									
            $outaddlayout_url = $this->View->base.'/index.php/psplayouts/outaddlayout/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];			
            $inaddlayout_url = $this->View->base.'/index.php/psplayouts/inaddlayout/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];			
			
			$dellayout_url = $this->View->base.'/index.php/psplayouts/dellayout/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];			
            $addtags_url = $this->View->base.'/index.php/psplayouts/addtags/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];			
            $uplayout_url = $this->View->base.'/index.php/psplayouts/uplayout/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];			
            $downlayout_url = $this->View->base.'/index.php/psplayouts/downlayout/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];

            $clearlayout_url = $this->View->base.'/index.php/psplayouts/clearlayout/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&startpos='.$layoutdata['startpos'].'&endspos='.$layoutdata['endspos'].'&endpos='.$layoutdata['endpos'];							
							
			$li = array();			
			$li[] = '<li class="mitem"><a href="'.$editlayout_url.'">修改布局</a></li>';
			!$layoutdata['istags'] && $li[] = '<li class="mitem"><a href="'.$addtags_url.'">添加模块</a></li>';
			$li[] = '<li class="mitem"><a href="'.$uplayout_url.'">向上移动</a></li>';
			$li[] = '<li class="mitem"><a href="'.$downlayout_url.'">向下移动</a></li>';
			$li[] = '<li class="mitem"><a href="'.$dellayout_url.'">删除</a></li>';				
			$li[] = '<li class="mitem"><a href="'.$outaddlayout_url.'">外加布局</a></li>';
			$li[] = '<li class="mitem"><a href="'.$inaddlayout_url.'">内加布局</a></li>';	
			$li[] = '<li class="mitem"><a href="'.$clearlayout_url.'">清空内部</a></li>';			
			$lis ='';
			foreach($li as $value){
			    $lis .= $value;
			}
return '<!--PSP::START-LAYOUTS-MOVE-start-->'.$css.'
<div class="modules" title="'.$layoutdata['id'].'"  >
<div class="frame cl m_title" style="position: relative; cursor: move; opacity: 0.95; visibility: visible;z-index: '.(100-$psplayoutcount).';">
	<div style="width: 49.9%; float: left;z-index: 100;">
		<div  style="margin: 1px;border: 0 none;height: 0;z-index: 100;" ></div>
	</div>
	<div  style="float: right;z-index: 100;">
		<div  style="margin: 1px;border: 0 none;height: 0;z-index: 100;"></div>
	</div>
	<div class="edit cl" style="z-index: 900;" >
		<span style="z-index: 900;" onclick="if(document.getElementById(\'edit_menu'.$psplayoutcount.'\').style.display==\'none\'){document.getElementById(\'edit_menu'.$psplayoutcount.'\').style.display=\'block\';}else{document.getElementById(\'edit_menu'.$psplayoutcount.'\').style.display=\'none\';}">编辑</span>
		<div id="edit_menu'.$psplayoutcount.'" class="edit-menu cl" style="display:none;clear: both;z-index: 900;">
			<ul style="z-index: 900;">
				'.$lis.'				
			</ul>
		</div>			
	</div>
    <div style="'.$style.'"><!--/PSP::START-LAYOUTS-MOVE-start-->';
        }else {		
            return '<div style="'.$style.'">';
        }		
		
	}
	
    public function PspLayoutParse($TemplateCode) {	
		$layouts = array();
		$layout_s = array();
		$layout_e = array();	
		$TemplateLen = strlen(trim($TemplateCode)); 
		$HtmlCode = ""; 
		$SearchTag = "<psp:layout";//标记的起始
		$SearchTagSE = ">";//标记的属性结束
		$SearchTagE = "</psp:layout>";//标记的范围结束	
		
		$StartPos = 0;//在循环中记录当前已经处理到的位置
		$count=0;
		$MyPos = 0;  
		$MyPosSE = 0; 
		$MyPosE = 0; 	
		$FindEnd = false; 
		$TagName = ""; 	
		While (!$FindEnd && $TemplateLen > 0) { 
			//找到下一个标记的起始位置
			$MyPos = strpos($TemplateCode,$SearchTag,$StartPos);
			if($MyPos ===false) {  
				$FindEnd = true;  
			}else{	
				$count++;	
				$MyPosSE = strpos($TemplateCode,$SearchTagSE,$MyPos);			
				$layout_s[$count]['id'] = $count;			
				$layout_s[$count]['startpos'] = $MyPos;	
				$layout_s[$count]['endspos'] = $MyPosSE;			
				$TagName = substr($TemplateCode, $MyPos + 11, $MyPosSE - $MyPos - 11); 	
				$arrTagName = explode(" ",$TagName);            			
				for($i=0;$i<count($arrTagName);$i++) { 
					$TempTagName = $arrTagName[$i];  
					//根据=再次进行分割
					$arrParamter = explode("=",$TempTagName); 
					if(isset($arrParamter[0]) && isset($arrParamter[1]) && !empty($arrParamter[0]) && !empty($arrParamter[1])) {
						$layout_s[$count]['style'][$arrParamter[0]] = $arrParamter[1];
					}
				}
				$StartPos = $MyPosSE +1;			
			}
		}
		$StartPos = 0;	
		$count=0;
		$MyPos = 0;  
		$MyPosSE = 0; 
		$MyPosE = 0; 	
		$FindEnd = false; 
		$TagName = ""; 	
		While (!$FindEnd && $TemplateLen > 0) { 
			//找到下一个标记的起始位置
			$MyPos = strpos($TemplateCode,$SearchTagE,$StartPos);
			if($MyPos ===false) {  
				$FindEnd = true;  
			}else{	
				$count++;				
				$layout_e[$count] = $MyPos;
				$StartPos = $MyPos + 13;			
			}
		}	
		if(count($layout_e) != count($layout_s)){//假如<psp:layout的数量和</psp:layout>的数量不同则退出
			return false;
		}
		foreach($layout_e as $endpos) {
			$num = 0;		
			foreach($layout_s as $k=> $pos) {		
				$kk = $this->findnextkey($pos,$layout_s);		
				if($endpos>=$pos['endspos'] && ( ( $kk && $endpos < $layout_s[$kk]['endspos']) || $kk===false )) {
					$layouts[$k] = $pos;
					$layouts[$k]['endpos'] = $endpos;
					$layouts[$k]['parentid'] = $this->findprevkey($pos,$layout_s);				
					unset($layout_s[$k]);				
				}			
			}
		}		
		foreach($layouts as $key=> $value) {	
            $temp = strpos($TemplateCode,'<psp:tags',$value['endspos']);		
			if($temp<$value['endpos']) {
				$layouts[$key]['istags'] = $temp;			
			}else {
				$layouts[$key]['istags'] = 0; 			
            }	
			$is = false;
			foreach($layouts as $key1=> $value1) {
				if($value['id']==$value1['parentid']) {
					$is = $value1['parentid'];
				}			
			} 
			if($is) {
				$layouts[$key]['istags'] = 1;
			}			
		}	
		return $layouts;
    }


    public function findnextkey($finddata,$data){
		if(empty($finddata))return false;
		if(empty($data))return false;
		$nextdata = false;
		reset($data);
		while($result=current($data)){
			if($finddata['startpos']==$result['startpos'] && $finddata['endspos']==$result['endspos'] ) {
				$nextdata = next($data);
				break;		
			}	
			next($data);   
		}
		if($nextdata) {
			foreach($data as $key => $value) {
				if($nextdata['startpos']==$value['startpos'] && $nextdata['endspos']==$value['endspos'] ) {
					return $key;
				}
			} 
		}	
		return false;
    }

    public function findprevkey($finddata,$data){
		if(empty($finddata))return false;
		if(empty($data))return false;
		$nextdata = 0;
		reset($data);
		while($result=current($data)){
			if($finddata['startpos']==$result['startpos'] && $finddata['endspos']==$result['endspos'] ) {
				$nextdata = prev($data);
				break;
			}	
			next($data);   
		}
		if($nextdata) {
			foreach($data as $key => $value) {
				if($nextdata['startpos']==$value['startpos'] && $nextdata['endspos']==$value['endspos'] ) {
					return $key;
				}
			} 
		}
		if($nextdata===false)return 0;	
		return false;
    }
	
    public function strAddDot($str = "") {
	    return str_replace(array('\\"',"{","}"),array("'",'".','."'),$str);		
	}		
	
/*
ICON label:(tablename,fields,order,limit,conditions,pageurl,htmlname,htmlconfig,iconname,iconfields,icondata='一个存数据的文件名',cachedatadir,cachefields,labels).
ICON  example :(<psp:tags tablename='content_1.con_id|content.id' fields='content.id:icon2|content_1.my_test:icon1' 
order='content.add_time desc' limit='0,10' conditions='is_show=1' pageurl='?app=new&act=index&cat=$GLOBALS[cat]' pageiconname='' 
htmlname='html1' htmlconfig='' iconname='title1' iconfields='' icondata='' cachedatadir='' cachefields='' labels='' 
powerlimit='scup-leaveword:0-index||job-index&&order-index&&aa-index||pic-index' activetime='2011-12-25 0:30:0,2011-12-25 1:30:0' 
activebefore='test'  activeafter='test'  activeperiod='test' iconbug='true' isselect='true'  />)

pageiconname属性是指页面分页页面要调用的某个标签的数据的iconname的值，用来调用数据

如果一个标签当中同时读取table,cache,icon数据，则三个数据都会调用到view类中，但显示时可用用不同的显示icon1,icon2等区别开来，如果三个数据同时使用icon1时则先后使用顺序为（从先到后）：icon>cache>table.
powerlimit这个主要用来控制某个用户是否有这个权限，如果用户有这个权限，则这个模块就显示出来，如果没有，就不显示出来，其值的写法是用'-'来区分，第一个可以是scup,admin，如果不写(如leaveword:0-index)，则默认为scup,app是leaveword:0(如果只写leaveword,则自动转化成leaveword:0),act是index，如果要几个权限来控制这个，可以使用||或,&&且来进行逻辑计算，比如scup-leaveword:0-index||job-index&&order-index&&aa-index||pic-index可能会变成'1||0&&1&&1||0',最后计算成1。

(activetime='2011-12-25 0:30:0,2011-12-25 1:30:0' activebefore='test'  activeafter='test'  activeperiod='test' )这四个标签的介绍.如果标签中存在activetime这个时间段，
则activebefore,activeafter,activeperiod分别表示在这个时间段之前该标签应该执行以该属性值为名的一个before的active的类函数,比如test,其文件存在scup/view/default/active/before/中，
比如test.active.before.php，activeafter表示在这个时间段之后执行，activeperiod表示在时间段期间运行，其中注意的是如果以该属性值为名的一个active的类函数有return返回值，则返回值会显示出
来，来代替该标签要显示的内容，也就是该标签的内容不显示了。
如果标签中不存在activetime这个时间段，则activebefore,activeafter,activeperiod分别表示:activebefore表示在运行该标签之前要运行的类函数(与存在activetime这个时间段类似)，
同时如果以该属性值为名的一个active的类函数有return返回值，则返回值会显示出来，来代替该标签要显示的内容，也就是该标签的内容不显示了。activeperiod失效了，activeafter表示在运行该标签之后要运行的类函数
改类的书写方法：文件名是如test.active.after.php,test.active.before.php,test.active.period.php,文件类名都是TestActive,但一定要继承BaseActive比如（class TestActive extends BaseActive）
类函数写法如:  function test() { return '[period]'; }
文件位置如：scup\view\default\active\after，scup\view\default\active\before，scup\view\default\active\period
activetime的值的写法是，两个时间之间用一个“,”号分开（英文状态下）
iconbug='true'的值只能是ture,false主要用来开启标签是否显示调用出来的数据，如果是true则显示，false则不显示，默认是不显示 
isselect='true' 设置是否开启GET['sc']数据产生的条件判断,默认是开启
ispage='false' 设置是否开启GET['page']数据产生的换页,默认是不开启
isdistinct='false' 设置是否开启去除相同的,默认是不开启
tagfunction='函数文件名'
tagfuncaliasvar='函数得到数据后的别名,主要跟tagfunction这个配合使用'
*/

    public function pspTagsToHtml($str = "") 
	{
	    if(empty($str)&&empty($temp_icon_array))return $str;		
		$oldstr = $this->filtrate($str);
        $tables ='';
		$fields = '';
		$conditions = '';
		$order = '';
		$limit = '';
		$pageurl = '';
		$pageiconname = '';
		$powerlimit = '';
				
        $activetime=''; 
		$activebefore='';  
		$activeafter=''; 
		$activeperiod='';
		
		$isselect='';			
		$ispage='';
		$isdistinct='';		
		
		$icon_str = $icon_str_1 ='';
        $cache_str = $cache_str_1 = '';
        $sql_str = $sql_str_1 = '';
		$str_temp = '';

		$tablename_array = array();
		$fields_array = array();
		$iconfields_array = array(); 
		$cachefields_array = array();
		$activetime_array = array();

        $temp_icon_array = array();
        if(empty($temp_icon_array))	{
		    $temp_icon_array = filterEmptyVar($this->strAttribute($str));
            foreach($temp_icon_array as $k =>$v) {
			    $temp_icon_array[$k] = $this->strAddDot($v);
			}            		
		}
        if(isset($temp_icon_array['tagfunction'])&&!empty($temp_icon_array['tagfunction'])){
	        $funstr = '';
			$filename = $this->View->viewRoot . DS .'tags' . DS .'tagfuncs'. DS .$temp_icon_array['tagfunction'] . '.php';
			if (file_exists($filename) && is_file($filename)){
				$tagfunc_code = "";
				if (!($tagfunc_code = file_get_contents($filename))){
					$tagfunc_code = "";
				}
                if(!empty($tagfunc_code)){
	                $datavarname = '';
	                if(isset($temp_icon_array['tagfuncaliasvar'])&&!empty($temp_icon_array['tagfuncaliasvar'])){
		                $datavarname = '$'.$temp_icon_array['tagfuncaliasvar'] .'= $TAGDB_'.$temp_icon_array['tagfunction'].';';
	                }
					$funstr = '<?php $TAGDB_'.$temp_icon_array['tagfunction'].' = Cache::read("'.$temp_icon_array['tagfunction'].'", "_psp_tagfunction_");
					if (empty($TAGDB_'.$temp_icon_array['tagfunction'].')) { ?>
                    '.$tagfunc_code.'
                   <?php  Cache::write("'.$temp_icon_array['tagfunction'].'", $TAGDB_'.$temp_icon_array['tagfunction'].', "_psp_tagfunction_");
					 } '.$datavarname.' ?>';	                
                }
				
			}
	        return '<!--PSP:TAGES:SET:START--><!--(name=['.$temp_icon_array['iconname'].'])-->'.$funstr.'<!--PSP:TAGES:SET:END-->';
        }		
        if(isset($temp_icon_array['labels'])&&!empty($temp_icon_array['labels'])){
            if(PspSession::check('TagsViewStartOrStop')) {
                return  '<!--PSP:TAGES:SET:START--><!--(data=['.$oldstr.'])-->'.'<!--PSP:TAGES:HTMLCODE:START-->'.
				'<?php '.'if (!defined("PSPVIEW_MANAGE_SRUE")) '.'{ ?> <?php'.' define("PSPVIEW_MANAGE_SRUE",1);'.'?>'.'
                        <SCRIPT LANGUAGE="JavaScript">
                            var jumpto=true;
                            function showlabel_(obj,mouse,admin_url,iconname,pagename,data,app,act,webroot){
	                            if(mouse=="over"){
								    obj.parentNode.style.borderWidth="1px";									
		                            obj.style.filter="Alpha(Opacity=80)";
		                            obj.style.cursor="hand";
		                            obj.title="点击修改";
	                            }else if(mouse=="out"){
		                            obj.style.filter="Alpha(Opacity=40)";
								    obj.parentNode.style.borderWidth="0px";	
	                            }else if(mouse=="click"&&jumpto==true){
		                            window.self.location=admin_url+"/index.php/tagsedit/viewmanageedit/?weburl='.$this->_urlencode(Request::$here ).'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&iconname="+iconname+"&app="+app+"&act="+act+"&webroot='.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).'&data="+data+"&divwidth="+parseInt(obj.style.width)+"&divheight="+parseInt(obj.style.height);	
	                            }
                            }
                            function ckjump_(type) {
	                            if(type==1){
		                            jumpto=true;
	                            }else{
		                            jumpto=false;
	                            }
                            }
                        </SCRIPT>'.'
<style>
.divstart_mask {-moz-user-select: none; background-color: #ccc; height: 100%; left: 0;opacity: 0.3;overflow: hidden;position: fixed;top: 0;width: 100%;}
.divstart_publish {
    background-color: #E3E9EE;
    border: 0 none;
    border-radius: 0 0 0 0;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
    text-align: left;
    width: 920px;
    z-index: 600;	
}
.divstart_publish .divstart_hd {
    border-bottom: 1px solid #E6E6E6;
    height: 40px;
    padding: 0 22px;
    position: relative;
    background-color: #4d3a29;
    background: url("<?php echo $this->_webroot("divstart/divstart.png"); ?>") repeat-x scroll 0 0 transparent;	
    line-height: 40px;	
}
.divstart_publish .divstart_hd h3 {
    color: #fff;
    float: left;
    font: 16px/54px "微软雅黑";
    font-size: 14px;
    font-weight: bold;	
    line-height: 40px;		
}
.divstart_publish .divstart_close {
    background: url("<?php echo $this->_webroot("divstart/publish-spr.png"); ?>") no-repeat scroll 0 0 transparent;
    height: 16px;
    overflow: hidden;
    position: absolute;
    right: 25px;
    text-indent: -9999px;
    top: 13px;
    width: 16px;
}
.divstart_publish .divstart_close:hover {
    background-position: -16px 0;
}

</style>
    

<div class="divstart_mask" tabindex="-1" id="divstart_mask" unselectable="on" style="z-index: 9000; display:none;"></div>
<div class="divstart_publish" style="display:none; position:fixed;left:0px;right:0px;width:920px;margin-left:auto;margin-right:auto;margin-top:60px;z-index: 9002;" id="divstart_genGoodsPanel" _fixed="true" data-bind-fixed="true">
	<div  class="panel-content">
		<div class="divstart_hd"><h3>页面装修</h3></div>
        <iframe width="920" scrolling="auto" height="600" id="div_start_or_drop1"  frameborder="0" ></iframe>
		<div class="ft"></div>
	</div>
	<span class="divstart_close" style="border-bottom: 0px solid #CCCCCC;margin-bottom: 0px;padding: 0px 0px;"></span>
</div>							
<script>
jQuery(function($){
//点击弹出确认层
$(".divstartordrop").click(function(e) {	
	if ($("#divstart_genGoodsPanel").css("display") == "none") {	
		$("#divstart_genGoodsPanel").show();
		$("#divstart_mask").show();	
		var url = $(this).attr("rel");
		$("#div_start_or_drop1").attr("src",url);		
	} else {
		$("#divstart_genGoodsPanel").hide();
		$("#divstart_mask").hide();		
	}

});				
$(".divstart_close").click(function(e) {
	if ($("#divstart_genGoodsPanel").css("display") == "none") {
		$("#divstart_genGoodsPanel").show();
		$("#divstart_mask").show();		
	} else {
		$("#divstart_genGoodsPanel").hide();
		$("#divstart_mask").hide();		
	}
});
   }
)
</script>							
						'.
				'<?php } ?>'.
				'<div  style="cursor: pointer;border-style:dashed;border-color:#0099FF;border-width:0px;z-index: 200;">        
                    <div   class="divstartordrop"  id="psp_view_manage_'.$temp_icon_array['iconname'].'" style="filter:alpha(opacity=50);position: absolute; border: 1px solid #0099FF; z-index: 189; color: rgb(0, 0, 0); text-align: left; opacity: 0.4; width: 80px; height:30px; background-color:#A6A6FF;"
						onmouseover="showlabel_(this,\'over\',\''.$this->View->base.'\',\''.$temp_icon_array['iconname'].'\',\''.$this->View->viewFilename.'\',\''.$oldstr.'\',\''.Request::$params['controller'].'\',\''.Request::$params['action'].'\',\''.$this->View->viewRoot.'\');" 
					    onmouseout="showlabel_(this,\'out\',\''.$this->View->base.'\',\''.$temp_icon_array['iconname'].'\',\''.$this->View->viewFilename.'\',\''.$oldstr.'\',\''.Request::$params['controller'].'\',\''.Request::$params['action'].'\',\''.$this->View->viewRoot.'\');" 
						rel="'.$this->View->base.'/index.php/tagsedit/viewmanageedit/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&iconname='.$temp_icon_array['iconname'].'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&data='.$oldstr.'&divwidth=100&divheight=100">
						<div onmouseover="ckjump_(0);" onmouseout="ckjump_(1);" style="position: absolute; width: 15px; height: 15px;  right: 0px; bottom: 0px; clear: both;font-size: 1px; line-height: 0%;"></div>
				</div>'.'<!--PSP:TAGES:HTMLCODE:END-->'.$temp_icon_array['labels'].'<!--PSP:TAGES:HTMLCODE:START-->'.'<div style="margin: 0px; padding: 0px; border: 0px none; clear: both;"></div></div>'.'<!--PSP:TAGES:SET:END-->';		
		    }else {
                return '<!--PSP:TAGES:SET:START--><!--(name=['.$temp_icon_array['iconname'].'])-->'.$temp_icon_array['labels'].'<!--PSP:TAGES:SET:END-->';		
		    }		
	    }

        if(isset($temp_icon_array['order'])){
		$order = ''.$temp_icon_array['order'];		
		}

        if(isset($temp_icon_array['limit'])){
		$limit = ''.$temp_icon_array['limit'];		
		}

        if(isset($temp_icon_array['conditions'])){
		$conditions = ''.$temp_icon_array['conditions'];		
		}
		
		if(Param::read('PSP_SC_SELECT_STR')) {
			if(isset($temp_icon_array['isselect']) && $temp_icon_array['isselect']=='true'){
				if(empty($conditions)) {
				    $conditions = Param::read('PSP_SC_SELECT_STR');
				}else {
				    $conditions .= ' and '.Param::read('PSP_SC_SELECT_STR');				
				}			
			}		
		}
		
        if(isset($temp_icon_array['ispage'])){
		    $ispage = ''.$temp_icon_array['ispage'];		
		}else {
		    $ispage = 'false';
        }	
        	
		$isdistinct='false';
        if(isset($temp_icon_array['isdistinct']) && $temp_icon_array['isdistinct']=='true'){
		    $isdistinct = 'true';		
		}
		        
        if(isset($temp_icon_array['pageurl'])){
		    $pageurl = ''.$temp_icon_array['pageurl'];		
		}
		
        if(isset($temp_icon_array['pageiconname']))	{
		    $pageiconname = ''.$temp_icon_array['pageiconname'];		
		}	
			
        if(isset($temp_icon_array['powerlimit'])){
		    $powerlimit = ''.$temp_icon_array['powerlimit'];		
		}			
		
	    if(isset($temp_icon_array['activebefore']))	{
		    $activebefore = ''.$temp_icon_array['activebefore'];		
		}	
		
		if(isset($temp_icon_array['activeafter'])){
		    $activeafter = ''.$temp_icon_array['activeafter'];		
		}
			
		if(isset($temp_icon_array['activeperiod']))	{
		    $activeperiod = ''.$temp_icon_array['activeperiod'];		
		}	
				
        if(isset($temp_icon_array['activetime'])){
		    $activetime = ''.$temp_icon_array['activetime'];				
		}
		
        if(isset($temp_icon_array['tablename'])&&!empty($temp_icon_array['tablename']))	{
		    $temp = $temp1 = array();	
		    $temp = explode("|",$temp_icon_array['tablename']);			
            $temp = $this->del_valueempty_var($temp);
			$num=1;
            foreach($temp as $key => $value){
		        $temp1 = explode(".",$value);
				if(isset($temp1[1])){
				    $tablename_array[$num]['table'] = $temp1[0];
				    $tablename_array[$num]['field'] = $temp1[1];
				}else{
				    $tablename_array[$num]['table'] = $temp1[0];
				    $tablename_array[$num]['field'] = 0;			
				}
				$num++;
			}
		}

        if(isset($temp_icon_array['fields'])&&!empty($temp_icon_array['fields'])){
		    $temp = $temp1 = array();	
		    $temp = explode("|",$temp_icon_array['fields']);			
            $temp = $this->del_valueempty_var($temp);
            foreach($temp as $key => $value){
		        $temp1 = explode(":",$value);
				if(isset($temp1[1])){
				$fields_array[$temp1[0]] = $temp1[1];
				}else{
				$fields_array[$temp1[0]] = 0;				
				}
			}
		}

        if(isset($temp_icon_array['iconfields'])&&!empty($temp_icon_array['iconfields'])){
		    $temp = $temp1 = array();	
		    $temp = explode("|",$temp_icon_array['iconfields']);			
            $temp = $this->del_valueempty_var($temp);
            foreach($temp as $key => $value){
		        $temp1 = explode(":",$value);
				if(isset($temp1[0])&&isset($temp1[1])){
				$iconfields_array[$temp1[1]] = $temp1[0];
				}
			}
		}

        if(isset($temp_icon_array['cachefields'])&&!empty($temp_icon_array['cachefields']))	{
		    $temp = $temp1 = array();	
		    $temp = explode("|",$temp_icon_array['cachefields']);			
            $temp = $this->del_valueempty_var($temp);
            foreach($temp as $key => $value){
		        $temp1 = explode(":",$value);
				if(isset($temp1[0])&&isset($temp1[1])){
				$cachefields_array[$temp1[1]] = $temp1[0];
				}
			}
		}

		if(isset($temp_icon_array['tablename'])&&isset($temp_icon_array['fields'])&&!empty($temp_icon_array['tablename'])&&!empty($temp_icon_array['fields'])){     
			$temp_on = '';
			$table_pre_key = '';
			$table_pre_value = '';
            if(count($tablename_array)==1){
			    $tables = $this->DbPrefix.$tablename_array[1]['table']. ' '.$tablename_array[1]['table'];
			} else	{
                for($num=1;$num<=count($tablename_array);$num++) {
				    if(empty($tablename_array[$num]['field'])){$tablename_array[$num]['field'] = ' ';}

                    if(isset($tablename_array[$num+1])&&$num==1) {
                        $tables.= $this->DbPrefix.$tablename_array[$num]['table'] . ' '.$tablename_array[$num]['table'].' LEFT JOIN '.$this->DbPrefix.$tablename_array[$num+1]['table'] . ' '.$tablename_array[$num+1]['table'].' ON '. $tablename_array[$num]['table'] .'.'.$tablename_array[$num]['field'].'='. $tablename_array[$num+1]['table'] .'.'.$tablename_array[$num+1]['field'].' ';
				    } else {   
					    if(isset($tablename_array[$num+1])) {
	                        $tables.= ' LEFT JOIN '.$this->DbPrefix.$tablename_array[$num+1]['table'] . ' '.$tablename_array[$num+1]['table'].' ON '. 
							$tablename_array[$num]['table'] .'.'.$tablename_array[$num]['field'].'='. $tablename_array[$num+1]['table'] .'.'
							.$tablename_array[$num+1]['field'].' ';						  
					    }
				    }
		        }	
			}

			foreach($fields_array as $key => $value){
				if(empty($value)){
					$fields.= $key . ' ,';			
				}else{
					$fields.= $key . ' AS '.$value.' ,';			
				}

			}
  		    $fields = substr($fields, 0,-1);
			$sql_str =  '$this->TagsModel("fieldlist_'.$temp_icon_array['iconname'].'_db'.'",array("table" => "'.$tables.'","fields" => "'.$fields.'","conditions" => "'.$conditions.'","order" => "'.$order.'","limit" => "'.$limit.'","url" =>"'.$pageurl.'","ispage"=>'.$ispage.',"isdistinct"=>'.$isdistinct.'));';
			$sql_str_1 =  '$this->TagsModel("'.$temp_icon_array['iconname'].''.'",array("table" => "'.$tables.'","fields" => "'.$fields.'","conditions" => "'.$conditions.'","order" => "'.$order.'","limit" => "'.$limit.'","url" =>"'.$pageurl.'","ispage"=>'.$ispage.',"isdistinct"=>'.$isdistinct.'));';
		}
            
        if(isset($temp_icon_array['cachedatadir'])&&!empty($temp_icon_array['cachedatadir'])&&isset($temp_icon_array['cachefields'])&&!empty($temp_icon_array['cachefields']))
		{             
			$paths = Loader::build('config');			
			$paths[] = TMP;
			$filename1 = null;
			foreach ($paths as $path) {
				if( file_exists($path . DS . $temp_icon_array['cachedatadir'] ) ) {
				    $filename1 = $path . DS . $temp_icon_array['cachedatadir'];
					break;
				}	
			}		     
		    if ($filename1 !==null ) {
			    if (!is_file($filename1)) {
                    $cache_str='';
			        $cachefields_array = array();
			    } else {
			        $cache_str =  ' $this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_cache'.'"] = $this->TagsCache(\''.$filename1.'\');';
				    $cache_str_1 =  ' $this->viewVars["'.$temp_icon_array['iconname'].''.'"] = $this->TagsCache(\''.$filename1.'\');';
				}
		    } else {
				$cache_str='';
				$cachefields_array = array();
		    }
		}

        if(isset($temp_icon_array['icondata'])&&!empty($temp_icon_array['icondata'])&&isset($temp_icon_array['iconfields'])&&!empty($temp_icon_array['iconfields'])){
		    $filename2 = $this->View->viewRoot . DS .'tags' . DS . 'tempdata' . DS . $temp_icon_array['icondata'].'.tags';
		    if (file_exists($filename2))  {
			    if (!is_file($filename2)) {
 		            $iconfields_array = array();       
		            $icon_str = '';
			    } else {
			        $icon_str =  ' $this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_icon'.'"] = $this->TagsCache(\''.$filename2.'\',"tags");';
				    $icon_str_1 =  ' $this->viewVars["'.$temp_icon_array['iconname'].''.'"] = $this->TagsCache(\''.$filename2.'\',"tags");';
				}   
		    } else {
 		        $iconfields_array = array();       
		        $icon_str = '';
		    }
		}
		
	    $this->div_icon = include ($this->View->viewRoot . DS .'tags' . DS . 'tags.php');
		$filename = $this->View->viewRoot . DS .'tags' . DS .$temp_icon_array['htmlname'] . '.html';
		if (file_exists($filename)) 
		{
			if (!is_file($filename)) 
			{
				$html_code = "";
			}
			$html_code = "";
			if (!($html_code = file_get_contents($filename))){
				$html_code = "";
			}
		}else{
            $html_code = $this->div_icon[$temp_icon_array['htmlname']]['html'];
		}
		$html_code = preg_replace("/\<psp\:filedlist\>(.+?)\<\/psp\:filedlist\>/is", "", $html_code); 
		
		preg_replace("/\<psp\:htmlurl\>\s*(.+?)\s*\<\/psp\:htmlurl\>/ies", "\$this->_filed_html_url_code('\\1')", $html_code);
		$html_code = preg_replace("/\<psp\:htmlurl\>(.+?)\<\/psp\:htmlurl\>/is", "", $html_code); 		
		$htmlurl = $this->_filedhtmlurlcode;
		if(isset($temp_icon_array['tablename']) && isset($htmlurl[$temp_icon_array['tablename']]) && !empty( $htmlurl[$temp_icon_array['tablename']]) ) {
		    $htmlurl = $htmlurl[$temp_icon_array['tablename']];
		}else if( isset($htmlurl['[default]']) && !empty( $htmlurl['[default]']) ) {
		    $htmlurl = $htmlurl['[default]'];
		}else {
		    $htmlurl = array();
		}
		if(!empty($htmlurl)) {//替换{[htmlurl1]},{[htmlurl2]}
		    $keyarr = array_keys($htmlurl);
			foreach($keyarr as $k => $v) {
			    $keyarr[$k] = '{['.$v.']}';
			}
		    $html_code = str_replace($keyarr,array_values($htmlurl),$html_code);		       
		}

        if($temp_icon_array['htmlname']&&!empty($html_code)){
            foreach($iconfields_array as $key => $value){
	            $html_code = str_replace($key,$value,$html_code);	
			}
            foreach($cachefields_array as $key => $value){
	            $html_code = str_replace($key,$value,$html_code);	
			}
            $temp_replace_str = '';
			if($sql_str){
                $temp_replace_str = '$this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_db"]["data"]';			
			}
			if($cache_str){
                $temp_replace_str = '$this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_cache"]';			
			}
			if($icon_str){
                $temp_replace_str = '$this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_icon"]';			
			}
  
			if($temp_replace_str == ''){
			    if(!empty($pageiconname)) {
            $temp_replace_str = 'array()';
		    $temp_str = str_replace(array('PSP_FIELDLIST_DATA_DEFAULT','PSP_FIELDLIST_PAGE','PSP_FIELDLIST_DATA_DB','PSP_FIELDLIST_DATA_CACHE','PSP_FIELDLIST_DATA_ICON'),array($temp_replace_str,'$this->viewVars["fieldlist_'.$temp_icon_array['pageiconname'].'_db"]["page"]',$temp_replace_str,$temp_replace_str,$temp_replace_str),$html_code);/*数据标签与分页标签替换*/					  
				} else {
            $temp_replace_str = 'array()';
		    $temp_str = str_replace(array('PSP_FIELDLIST_DATA_DEFAULT','PSP_FIELDLIST_PAGE','PSP_FIELDLIST_DATA_DB','PSP_FIELDLIST_DATA_CACHE','PSP_FIELDLIST_DATA_ICON'),array($temp_replace_str,$temp_replace_str,$temp_replace_str,$temp_replace_str,$temp_replace_str),$html_code);/*数据标签与分页标签替换*/					  
				}
		 
			} else	{
		    $temp_str = str_replace(array('PSP_FIELDLIST_DATA_DEFAULT','PSP_FIELDLIST_PAGE','PSP_FIELDLIST_DATA_DB','PSP_FIELDLIST_DATA_CACHE','PSP_FIELDLIST_DATA_ICON'),array($temp_replace_str,'$this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_db"]["page"]','$this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_db"]["data"]','$this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_cache"]','$this->viewVars["fieldlist_'.$temp_icon_array['iconname'].'_icon"]'),$html_code);/*数据标签与分页标签替换*/			 
			}
		}else{ 				
            if(isset($temp_icon_array['iconbug'])&&$temp_icon_array['iconbug']=='true')	{
                return '<!--PSP:TAGES:SET:START--><!--(name=['.$temp_icon_array['iconname'].'])-->Get database string :<br/>'.$sql_str.'<br/><br/>Get cached data string :'.$cache_str.'<br/><br/>Get icon array :'.var_export($temp_icon_array , true).'<br/><br/>'.'<!--PSP:TAGES:SET:END-->';	 		 
			}else{
                return '<!--PSP:TAGES:SET:START--><!--(name=['.$temp_icon_array['iconname'].'])--><?php '.$sql_str_1.$cache_str_1.$icon_str_1.'?><!--PSP:TAGES:SET:END-->';	
			}
		}

        if(PspSession::check('TagsViewStartOrStop')){		
            return   '<!--PSP:TAGES:SET:START--><!--(data=['.$oldstr.'])-->'.'<!--PSP:TAGES:HTMLCODE:START-->'.
			         '<?php '.'if (!defined("PSPVIEW_MANAGE_SRUE")) '.'{ ?> <?php'.' define("PSPVIEW_MANAGE_SRUE",1);'.'?>'.'
                        <SCRIPT LANGUAGE="JavaScript">
                            var jumpto=true;
                            function showlabel_(obj,mouse,admin_url,iconname,pagename,data,app,act,webroot){
	                            if(mouse=="over"){
								    obj.parentNode.style.borderWidth="1px";									
		                            obj.style.filter="Alpha(Opacity=80)";
		                            obj.style.cursor="hand";
		                            obj.title="点击修改";
	                            }else if(mouse=="out"){
		                            obj.style.filter="Alpha(Opacity=40)";
								    obj.parentNode.style.borderWidth="0px";									
	                            }else if(mouse=="click"&&jumpto==true){
		                            window.self.location=admin_url+"/index.php/tagsedit/viewmanageedit/?weburl='.$this->_urlencode(Request::$here ).'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&iconname="+iconname+"&app="+app+"&act="+act+"&webroot='.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).'&data="+data+"&divwidth="+parseInt(obj.style.width)+"&divheight="+parseInt(obj.style.height);		
	                            }
                            }
                            function ckjump_(type){
	                            if(type==1){
		                            jumpto=true;
	                            }else{
		                            jumpto=false;
	                            }
                            }
                        </SCRIPT>'.'
<style>
.divstart_mask {-moz-user-select: none; background-color: #ccc; height: 100%; left: 0;opacity: 0.3;overflow: hidden;position: fixed;top: 0;width: 100%;}
.divstart_publish {
    background-color: #E3E9EE;
    border: 0 none;
    border-radius: 0 0 0 0;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
    text-align: left;
    width: 920px;
    z-index: 600;	
}
.divstart_publish .divstart_hd {
    border-bottom: 1px solid #E6E6E6;
    height: 40px;
    padding: 0 22px;
    position: relative;
    background-color: #4d3a29;
    background: url("<?php echo $this->_webroot("divstart/divstart.png"); ?>") repeat-x scroll 0 0 transparent;	
    line-height: 40px;	
}
.divstart_publish .divstart_hd h3 {
    color: #fff;
    float: left;
    font: 16px/54px "微软雅黑";
    font-size: 14px;
    font-weight: bold;	
    line-height: 40px;		
}
.divstart_publish .divstart_close {
    background: url("<?php echo $this->_webroot("divstart/publish-spr.png"); ?>") no-repeat scroll 0 0 transparent;
    height: 16px;
    overflow: hidden;
    position: absolute;
    right: 25px;
    text-indent: -9999px;
    top: 13px;
    width: 16px;
}
.divstart_publish .divstart_close:hover {
    background-position: -16px 0;
}

</style>
<div class="divstart_mask" tabindex="-1" id="divstart_mask" unselectable="on" style="z-index: 9000; display:none;"></div>
<div class="divstart_publish" style="display:none; position:fixed;left:0px;right:0px;width:920px;margin-left:auto;margin-right:auto;margin-top:60px;z-index: 9002;" id="divstart_genGoodsPanel" _fixed="true" data-bind-fixed="true">
	<div  class="panel-content">
		<div class="divstart_hd"><h3>页面装修</h3></div>
        <iframe width="920" scrolling="auto" height="550" id="div_start_or_drop1"  frameborder="0" ></iframe>
		<div class="ft"></div>
	</div>
	<span class="divstart_close" style="border-bottom: 0px solid #CCCCCC;margin-bottom: 0px;padding: 0px 0px;"></span>
</div>							
<script>
jQuery(function($){
//点击弹出确认层
$(".divstartordrop").click(function(e) {	
	if ($("#divstart_genGoodsPanel").css("display") == "none") {	
		$("#divstart_genGoodsPanel").show();
		$("#divstart_mask").show();	
		var url = $(this).attr("rel");
		$("#div_start_or_drop1").attr("src",url);		
	} else {
		$("#divstart_genGoodsPanel").hide();
		$("#divstart_mask").hide();		
	}

});				
$(".divstart_close").click(function(e) {
	if ($("#divstart_genGoodsPanel").css("display") == "none") {
		$("#divstart_genGoodsPanel").show();
		$("#divstart_mask").show();		
	} else {
		$("#divstart_genGoodsPanel").hide();
		$("#divstart_mask").hide();		
	}
});
   }
)
</script>										
						'.
					'<?php } ?>'.
					'<div  style="cursor: pointer;border-style:dashed;border-color:#0099FF;border-width:0px;z-index: 200;">        
                        <div  class="divstartordrop" id="psp_view_manage_'.$temp_icon_array['iconname'].'" style="filter:alpha(opacity=50);position: absolute; border: 1px solid #0099FF; z-index: 189; color: rgb(0, 0, 0); text-align: left; opacity: 0.4; width: 80px; height:30px; background-color:#A6A6FF;" 
						    onmouseover="showlabel_(this,\'over\',\''.$this->View->base.'\',\''.$temp_icon_array['iconname'].'\',\''.$this->View->viewFilename.'\',\''.$oldstr.'\',\''.Request::$params['controller'].'\',\''.Request::$params['action'].'\',\''.$this->View->viewRoot.'\');" 
							onmouseout="showlabel_(this,\'out\',\''.$this->View->base.'\',\''.$temp_icon_array['iconname'].'\',\''.$this->View->viewFilename.'\',\''.$oldstr.'\',\''.Request::$params['controller'].'\',\''.Request::$params['action'].'\',\''.$this->View->viewRoot.'\');" 
							rel="'.$this->View->base.'/index.php/tagsedit/viewmanageedit/?weburl='.$this->_urlencode(Request::$here ).
							'&compeld='.$this->_urlencode( $this->View->viewViewsmanagesPath ).'&iconname='.$temp_icon_array['iconname'].'&app='.Request::$params['controller'].'&act='.Request::$params['action'].'&webroot='
							.$this->_urlencode( $this->View->viewRoot ).'&pagename='.$this->_urlencode( $this->View->viewFilename ).
							'&data='.$oldstr.'&divwidth=100&divheight=100"
							>
							<div onmouseover="ckjump_(0);" onmouseout="ckjump_(1);" style="position: absolute; width: 15px; height: 15px;  right: 0px; bottom: 0px; clear: both;font-size: 1px; line-height: 0%;"></div>
						</div>'.
					'<!--PSP:TAGES:HTMLCODE:END-->'.
					'<?php '.$sql_str.$cache_str.$icon_str.'?>'.$temp_str.'<!--PSP:TAGES:HTMLCODE:START-->'.
					'<div style="margin: 0px; padding: 0px; border: 0px none; clear: both;"></div></div>'.'<!--PSP:TAGES:HTMLCODE:END-->'.'<!--PSP:TAGES:SET:END-->';		
		}else{
		    $activestr_head_start = '';
		    $activestr_head_else = '';		   
		    $activestr_head_end = '';
		   		   
		    $activestr_footer_start = '';
		    $activestr_footer_else = '';		   	
		    $activestr_footer_end = '';	
		   	   	
            if( $activebefore || $activeafter || $activeperiod ){
			    $activestr_head_start  = ' $PSP_activestr = $this->TagsActive('."'$activetime','$activebefore','$activeperiod','$activeafter'".'); if ( empty( $PSP_activestr ) ) { ';
		        $activestr_head_else = ' } else { ?> <?php echo $PSP_activestr ; ?> ';		       
			    $activestr_head_end = '<?php  } ';				
					
			    if($activeafter&&empty($activetime)){
		           $activestr_footer_start = ' $this->TagsActive('."'$activetime','$activebefore','$activeperiod','$activeafter'".'); ';
		           $activestr_footer_else = '';		   	
		           $activestr_footer_end = '';							
				}
			    if($activeperiod&&empty($activetime)){
		           $activestr_head_start = ' ';
		           $activestr_head_else = ' ';		   
		           $activestr_head_end = ' ';									
				}
			    if($activebefore&&empty($activetime)){				
			       $activestr_head_start  = ' $PSP_activestr = $this->TagsActive('."'$activetime','$activebefore','$activeperiod','$activeafter'".'); if ( empty( $PSP_activestr ) ) { ';
		           $activestr_head_else = ' } else { ?> <?php echo $PSP_activestr ; ?> ';		       
			       $activestr_head_end = '<?php  } ';							
				}	

		    }		   	
						
		    if($powerlimit) {
                return '<!--PSP:TAGES:SET:START--><!--(name=['.$temp_icon_array['iconname'].'])--><?php if (icon_power_limit("'.$powerlimit.'")) { '.$activestr_head_start.$sql_str.$cache_str.$icon_str.'?>'.$temp_str.'<?php '.$activestr_head_else.$activestr_head_end.$activestr_footer_start.' }?> <!--PSP:TAGES:SET:END-->';	
		    }else {
                return '<!--PSP:TAGES:SET:START--><!--(name=['.$temp_icon_array['iconname'].'])--><?php '.$activestr_head_start.$sql_str.$cache_str.$icon_str.'?>'.$temp_str.'<?php '.$activestr_head_else.$activestr_head_end.$activestr_footer_start.' ?><!--PSP:TAGES:SET:END-->';			
		    }
			
		}
				
	} 

	
/*
<psp:htmlurl>
goods => htmlurl1:good/index/{$_value['icon1']}|htmlurl2:good/index/{$_value['icon1']}?&name={$_value['icon2']}| ;
shop_info => htmlurl1:shop/index/{$_value['icon1']}|htmlurl2:shop/index/{$_value['icon1']}?&name={$_value['icon2']}| ;
[default] => htmlurl1:default/index/{$_value["icon1"]}|htmlurl2:default/index/{$_value["icon1"]}?&name={$_value["icon2"]}| ;
</psp:htmlurl>处理这里面的字符
替换{[htmlurl1]},{[htmlurl2]}
*/
	function _filed_html_url_code($str = '') {
		$str= str_replace(array("\r","\n",'\"',"\'"),array('','',"'","'"),$str );	
		$temp = filterEmptyVar(explode(";",$str));
		$temp1 = $temp3= array();
        foreach($temp as $key => $value) {
            $temp2 = filterEmptyVar(explode("=>",$value)) ;
			$temp1[trim($temp2[0])] = trim($temp2[1]);			
        }	
        foreach($temp1 as $key => $value) {
            $temp2 = filterEmptyVar(explode("|",$value)) ;
			foreach($temp2 as $value1) {
			    $value1 = trim($value1);
				$temp4 = filterEmptyVar(explode(":",$value1)) ;
				$temp3[$key][trim($temp4[0])] = '<?php echo $this->_url(\''.str_replace(array('{','}'), array('\'.','.\''), trim($temp4[1])).'\');?>';
			}						
        }
	    $this->_filedhtmlurlcode = $temp3 ;
	}		
	
	
	
    public function _urlencode($msg){
		$msg = str_replace('-',';gang;',$msg);
		$msg = urlencode($msg);		
		return $msg;
	}

    public function filtrate($msg){
		$msg = str_replace('=',';deng;',$msg);
		$msg = str_replace(' ',';kong;',$msg);
		$msg = str_replace('"',';shuang;',$msg);
		$msg = str_replace("'",';dang;',$msg);
		$msg = str_replace("&&",';and;',$msg);		
		$msg = str_replace("||",';or;',$msg);
		$msg = str_replace("-",';gang;',$msg);					
		return $msg;
	}

    public function strAttribute($str='',$SourceMaxSize = 1024,$CharToLow = FALSE)
    {
	    $Items =array();
        $Count = -1;
		$strLen = 0;
		$d = "";
		$tmpatt="";
		$tmpvalue="";
		$startdd=-1;
		$ddtag="";
		$j = 0;
		$str = trim(preg_replace("/[ \t\r\n]{1,}/"," ",$str));
		$strLen = strlen($str);
		$str .= " ";
        if($strLen>0&&$strLen<=$SourceMaxSize)
        {
	   //遍历源字符串，获得各属性
		for($i=$j;$i<$strLen;$i++)
		{
			$d = $str[$i];
			//获得属性的键
			if($startdd==-1){
				if($d!="=")	$tmpatt .= $d;
				else{
					$tmpatt = strtolower(trim($tmpatt));
					$startdd=0;
				}
			}
			//检测属性值是用什么包围的，允许使用 '' "" 或空白
			else if($startdd==0){
				switch($d){
					case ' ':
						continue;
						break;
					case '\'':
						$ddtag='\'';
						$startdd=1;
						break;
					case '"':
						$ddtag='"';
						$startdd=1;
						break;
					default:
						$tmpvalue.=$d;
						$ddtag=' ';
						$startdd=1;
						break;
				}
			}
			//获得属性的值
			else if($startdd==1)
			{
				if($d==$ddtag){
					$Count++;
          if($CharToLow) $Items[$tmpatt] = strtolower(trim($tmpvalue));
					else $Items[$tmpatt] = trim($tmpvalue);
					$tmpatt = "";
					$tmpvalue = "";
					$startdd=-1;
				}
				else
					$tmpvalue.=$d;
			}
	    }//End for
	     //处理没有值的属性(必须放在结尾才有效)如："input type=radio name=t1 value=aaa checked"


	    if($tmpatt!="")
	    { 
		    $Items[$tmpatt] = "";
	    }
        return $Items;

        }
        return '';      

    }



    function _get_content_html($str="",$temp_array= array(),$tips=array())
	{   
		$str = preg_replace("/\<\!\-\-PHPSCUP\:DELSTART\-\-\>\s*(.+?)\s*\<\!\-\-PHPSCUP\:DELEND\-\-\>/ies", "\$this->_content_html_del('\\1')", $str);
		$str = str_replace(array("<!--PHPSCUP:DELSTART-->","<!--PHPSCUP:DELEND-->"),array(' ',' '),$str);
		
		$html_str = preg_replace("/\<\!\-\-PHPSCUP\:START\>\s*(.+?)\s*\<PHPSCUP\:END\-\-\>/ies", "\$this->_content_html_deal('\\1',\$temp_array,\$tips)", $str);
		
		return stripslashes($html_str);
	}
    function _content_html_del($str="")
	{  
       return '';
	}

    function _content_html_deal($str="",$temp_array=array(),$tips=array())
	{  
	   if(empty($temp_array))
	   {
	   return '<!--PHPSCUP:START>'.$str.'<PHPSCUP:END-->';
	   }
	   $temp_str = '<!--PHPSCUP:START>'.$str.'<PHPSCUP:END--><!--PHPSCUP:DELSTART-->'; 
	   foreach($temp_array as $key =>$value)
	   { 
	        $temp_str .= str_replace(array("<PHPSCUP:LIST_ICON>","<PHPSCUP:LIST_CODE>","<PHPSCUP:CONTENT_ICON>","<PHPSCUP:CONTENT_CODE>","<PHPSCUP:CONTENT_TIPS>"),array($key,$value,$key,$value,$tips[$key]),$str);	      

	   }
 
       return $temp_str.'<!--PHPSCUP:DELEND-->';
	}




    function del_empty_var($array)
	{ 
	     foreach($array as $key => $value)
	     {
	        if(empty($value)&&empty($key))
	        {
	          unset($array[$key]);
	        }
	        if(($key=='disabled'&&empty($value))||($key=='selected'&&empty($value))||($key=='checked'&&empty($value)))
			{
	          unset($array[$key]);			
			}
	     }
	     return $array;
     }

    function del_valueempty_var($array)
	{ 
	     foreach($array as $key => $value)
	     {
	        if(empty($value))
	        {
	          unset($array[$key]);
	        }
	     }
	     return $array;
     }
 
  	function get_phpscupdiv( $id = 0,$appname = '',$filedir='') 
	{
	    $phpscupdiv_data = array();
	    $moduledata = $this->get_module_data($filedir);
	
		foreach($moduledata as $key => $value)
		{
		      if(!isset($value['appname']))
			  {
			  $value['appname'] ='';
			  }
		      if($id&&($value['id']==$id))
		      {
		       $tempdata = $value;		 
		      }		 
		      if($appname&&($value['appname']==$appname))
		      {
		      $tempdata = $value;		 
		      } 		
		}
									
		$module_config = unserialize($tempdata['config']);

        if(!is_array($module_config))$module_config = array();

		$phpdivdata = $this->get_div_data();

		foreach($module_config as $key => $value)
		{   
            $phpscupdiv_data[$key]['fieldname'] = $value['filed']['name'];
			$temp_phpscupdiv = '';
		 	foreach($phpdivdata as $key2 => $value2)
		    {
		       if($value2['config']['type'] == $value['form']['type'])
			   {
			    $temp_phpscupdiv = $value2['phpscupdiv'];
			   }
		    }
			
	   	   $temp_str = "type='".$value['form']['type']."' ";
		   $phpscupdiv_data[$key]['icon'] = $value['form']['icon'];
		   foreach($value['form'][$value['form']['type']] as $key1 => $value1)
		   {
            $temp_str .= $key1."='". $value1."' "; 
		   }
           $temp_str = $temp_str ." appname='".$this->appname."' ";
           $temp_str = $temp_str ." sxdata='".$value['form']['sx_data']."' ";
           $temp_str = $temp_str ." sxdatatype='".$value['form']['sxdatatype']."' ";	
		   $phpscupdiv_data[$key]['tips'] = $value['form']['tips'];		   	   		   
		   $phpscupdiv_data[$key]['phpdiv'] = str_replace(array('PHPSCUP_DIV',"<",">"),array($temp_str,"&lt;","&gt;"),$temp_phpscupdiv);
		   
		   $phpscupdiv_data[$key]['htmldiv'] = str_replace(array("<",">"),array("&lt;","&gt;"),$this->phpdiv_to_htmldiv($temp_str,$this->appname)); 
		   
		}		
        return $phpscupdiv_data;
	} 

	function get_module_data($filedir='module/module_list.php') 
	{
	    if(empty($this->module_data))
		{
		if(empty($filedir))$filedir='module/module_list.php';
	    $this->module_data = include (ROOT_PATH . '/data/'.$filedir);
		}
		return $this->module_data;		
		
	}
 
 	function get_module_list_array($id='',$filedir='') 
	{
        $list_array = $this->get_module_data($filedir);
        $temp_list_array = array();     
        foreach($list_array as $key=>$value)
		{
  
		    if($value['id']==$id)
			{
		      
		        $temparray = del_empty_var(explode("|",$value['filedlist'])); 
			    foreach($temparray as $key1=>$value1)
				{ 
				  $temp = array();
		          $temp = del_empty_var(explode(":",$value1)); 
		          $temp_list_array[$temp[0]] = '{$_value.'.$temp[1].'}';					  				
				}	
		        break;
			}

		}	
		return $temp_list_array; 	
	}

}


?>